﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Intorise.Common;
using System.Diagnostics;
using System.Threading;

namespace Model
{
    /// <summary>
    /// 任务
    /// </summary>
    public class MissionData
    {
        Dictionary<string, MissionBase> dict = new Dictionary<string, MissionBase>();

        public MissionData()
        {
            dict.Add("色即是空", new Mission_色即是空 { IDByte = new byte[] { 0xD4, 0x9D, 0x01, 0x00 }, Name = "色即是空" });
            dict.Add("破损的魔导师铠甲", new Mission_破损的魔导师铠甲 { IDByte = new byte[] { 0xCA, 0xA8, 0x0C }, Name = "破损的魔导师铠甲" });
            dict.Add("使用微端登录", new Mission_使用微端登录());
            dict.Add("转职", new Mission_转职());
            dict.Add("转职-帝王之书", new Mission_转职_帝王之书());
            dict.Add("转职-先知之魂", new Mission_转职_先知之魂());
            dict.Add("快速升级", new Mission_快速升级());
        }

        public MissionBase 色即是空 { get { return dict["色即是空"]; } }
        public MissionBase 破损的魔导师铠甲 { get { return dict["破损的魔导师铠甲"]; } }
        public MissionBase 使用微端登录 { get { return dict["使用微端登录"]; } }
        public MissionBase 转职 { get { return dict["转职"]; } }
        public MissionBase 转职_帝王之书 { get { return dict["转职-帝王之书"]; } }
        public MissionBase 转职_先知之魂 { get { return dict["转职-先知之魂"]; } }
        public MissionBase 快速升级 { get { return dict["快速升级"]; } }

        /// <summary>
        /// 所有任务
        /// </summary>
        public List<MissionBase> All { get { return dict.Values.ToList(); } }
    }

    /// <summary>
    /// 任务
    /// </summary>
    public abstract class MissionBase
    {
        protected static byte[] completedDataTag = new byte[] { 0x00, 0x00, 0x00, 0x0A, 0x00, 0x01, 0xD5, 0x8A, 0x00, 0x00 };

        /// <summary>
        /// 任务编号
        /// </summary>
        public byte[] IDByte { get; set; }

        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 任务是否已经完成
        /// </summary>
        public bool IsCompleted { get; set; }

        public abstract byte[] GetCompletedData();
    }

    /// <summary>
    /// 色即是空
    /// </summary>
    public class Mission_色即是空 : MissionBase
    {
        /// <summary>
        /// 获取传送到任务怪附近数据包
        /// </summary>
        /// <returns></returns>
        public byte[] GetGoMonsterData()
        {
            return new byte[] { 0x00, 0x00, 0x00, 0x10, 0x00, 0x02, 0x00, 0x8C, 0xDC, 0x9A, 0x0C, 0xF0, 0x01, 0x8E, 0x03, 0x00, 0x00, 0xD4, 0x9D, 0x01 };
        }

        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte);
        }

        /// <summary>
        /// 获取传送到完成任务NPC数据包
        /// </summary>
        /// <returns></returns>
        public byte[] GetGoSubmitNPCData()
        {
            return new byte[] { 0x00, 0x00, 0x00, 0x10, 0x00, 0x02, 0x00, 0x8C, 0xDC, 0x9A, 0x0C, 0xAE, 0x02, 0xE2, 0x02, 0x00, 0x00, 0xD4, 0x9D, 0x01 };
        }
    }

    /// <summary>
    /// 破损的魔导师铠甲
    /// </summary>
    public class Mission_破损的魔导师铠甲 : MissionBase
    {
        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte, new byte[] { 0x00 });
        }
    }

    /// <summary>
    /// 使用微端登录
    /// </summary>
    public class Mission_使用微端登录 : MissionBase
    {
        public Mission_使用微端登录()
        {
            IDByte = new byte[] { 0x94, 0x8E, 0x06 };
            Name = "使用微端登录";
        }

        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte, new byte[] { 0x00 });
        }
    }

    /// <summary>
    /// 转职
    /// </summary>
    public class Mission_转职 : MissionBase
    {
        public Mission_转职()
        {
            IDByte = new byte[] { 0xC0, 0xA9, 0x07 };
            Name = "转职";
        }

        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte, new byte[] { 0x00 });
        }
    }

    /// <summary>
    /// 转职_帝王之书
    /// </summary>
    public class Mission_转职_帝王之书 : MissionBase
    {
        public Mission_转职_帝王之书()
        {
            IDByte = new byte[] { 0xC2, 0xA9, 0x07 };
            Name = "转职-帝王之书";
        }

        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte, new byte[] { 0x00 });
        }
    }

    /// <summary>
    /// 转职_精灵之泪
    /// </summary>
    public class Mission_转职_先知之魂 : MissionBase
    {
        public Mission_转职_先知之魂()
        {
            IDByte = new byte[] { 0xC6, 0xA9, 0x07 };
            Name = "转职-先知之魂";
        }

        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte, new byte[] { 0x00 });
        }
    }

    /// <summary>
    /// 效率？快速升级？！
    /// </summary>
    public class Mission_快速升级 : MissionBase
    {
        public Mission_快速升级()
        {
            IDByte = new byte[] { 0xB6, 0x8D, 0x06 };
            Name = "快速升级";
        }

        /// <summary>
        /// 获取完成任务数据包
        /// </summary>
        /// <returns></returns>
        public override byte[] GetCompletedData()
        {
            return Tools.Contact(completedDataTag, IDByte, new byte[] { 0x00 });
        }
    }
}
